﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace Soft000.IDAL
{
    public interface IDALBase<T>
    {
        bool Add(T o);
        bool Update(T o);
        int Delete(long id);
        /// <summary>
        /// 根据Id返回数据对像
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <returns></returns>
        T GetById(long id);
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="strFileds">返回的字段，合部用"*"</param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="strOrders">排序字段</param>
        /// <param name="nNowPage">当前页</param>
        /// <param name="nPageSize">页的大小</param>
        /// <param name="ht">调用此存储过程最终所执行的SQL语句,输出参数，方便调试</param>
        /// <returns>DataSet数据集</returns>
        DataSet Paging(string strFileds, string strWhere, string strOrders, int nNowPage, int nPageSize, ref string strSql);
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="strTableName">数据表名</param>
        /// <param name="strFileds">返回的字段，合部用"*"</param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="strKeyFields">关键字，分页字段，此处为自动增长Id</param>
        /// <param name="strOrders">排序字段</param>
        /// <param name="KeyOrder">0按关键字升序分页 1按关键字降序分页</param>
        /// <param name="nNowPage">当前页</param>
        /// <param name="nPageSize">页的大小</param>
        /// <param name="ht">调用此存储过程最终所执行的SQL语句,输出参数，方便调试</param>
        /// <returns>DataSet数据集</returns>
        DataSet Paging(string strTableName, string strFileds, string strWhere, string strOrders, string strKeyFields, int KeyOrder, int nNowPage, int nPageSize, ref string strSql);
        /// <summary>
        /// 返回记录数
        /// </summary>
        /// <param name="strWhere">查询条件</param>
        /// <param name="strSql">存储过程最终执行的SQL语句，输出，方便出错时的调试，不需要可传null</param>
        /// <returns>返回记录数</returns>
        long GetRecordCount(string strWhere, ref string strSql);
    }
}
